
 # -------------------------------------------------------------------------- --
 #     AUTHOR                   : Yan zhongqian
 #     FILE NAME                : config.sh
 #     FILE DESCRIPTION         : Linux shell script file
 #     FIRST CREATION DATE      : 2020/10/30
 # --------------------------------------------------------------------------
 #     Version                  : 1.0
 #     Last Change              : 2020/10/30
## ************************************************************************** ##
#!/bin/bash
#-----------------------------------------------------------
#                COLOUR VARIABLES
#-----------------------------------------------------------
UNDL="\033[4m"    F6_E="\033[0m"    B_WT="\033[47m"
F_BL="\033[30m"   F_RD="\033[31m"   F_GR="\033[32m"
F_YL="\033[33m"   F_BU="\033[34m"   F_PU="\033[35m"
F_DG="\033[36m"   F_WT="\033[37m"   B_BL="\033[40m"
B_RE="\033[41m"   B_GR="\033[42m"   B_YL="\033[43m"
B_BU="\033[44m"   B_PR="\033[45m"   B_DG="\033[46m"

#-----------------------------------------------------------
#                  MAIN PROCESS
#-----------------------------------------------------------
# auto configure the bash_alias and  fun-simple
# 1. bash_aliases
if [ -f ~/.bash_aliases ];then
    mv ~/.bash_aliases ~/.bash_aliases_bp
    rm -rf ~/.bash_aliases
fi
ln -si  `pwd`/bash_aliases  ~/.bash_aliases
if [ $? -ne 0 ];then
    echo -e "$F_RD \t link bash_aliases failed, please check! $UNDL"
else
    echo -e "$F_GR \t link bash_aliases successful! $UNDL"
fi

# 2. ~/bin/functions-simple
if [ -d ~/bin ]; then
    if [ -f ~/bin/functions-simple ];then
        mv ~/bin/functions-simple ~/bin/functions-simple_bp
        rm -rf ~/bin/functions-simple
    fi
else
    mkdir -p  ~/bin
fi

rm -rf ~/bin/functions-simple
ln -s `pwd`/functions-simple  ~/bin/functions-simple
if [ $? -ne 0 ];then
    echo -e "$F_RD \t link functions-simple failed, please check! $UNDL"
else
    echo -e "$F_GR \t link functions-simple successful! $UNDL"
fi

# 3. bashrc
if [ -f ~/.bashrc ];then
    mv ~/.bashrc ~/.bashrc_bp
    rm -rf ~/.bashrc
fi
ln -si  `pwd`/bashrc  ~/.bashrc
if [ $? -ne 0 ];then
    echo -e "$F_RD \t link bashrc failed, please check! $UNDL"
else
    echo -e "$F_GR \t link bashrc successful! $UNDL"
fi

